TASK_DIR:=$(dir $(abspath $(lastword $(MAKEFILE_LIST))))

include ../config.mk

# Inputs
SRC := $(TASK_DIR)/src/compute_multiple_hypothesis_adjustment.R
CONFIG_FILE := $(TASK_DIR)/hand/config.yaml
OUTCOME_CONFIG_FILE := $(TASK_DIR)/../run_regressions/hand/outcome_sets.yaml
RESAMPLING_RESULTS_FILE := $(TASK_DIR)/../run_regressions/output/regression_output__fwer_resampling.csv
RESAMPLING_BY_SUBGROUP_RESULTS_FILE := $(TASK_DIR)/../run_regressions/output/regression_output__fwer_resampling_by_subgroup.csv

# One of the output files
OUT_FILE := $(OUT_DIR)/realized_risk_by_pathway.csv

$(OUT_FILE): $(SRC) $(TASK_FNS) $(CONFIG_FILE) $(OUTCOME_CONFIG_FILE) $(PROJECT_CONFIG) $(RESAMPLING_RESULTS_FILE)
	@mkdir -p $(OUT_DIR)
	@$(R_script) $(SRC) \
		--CONFIG_FILE=$(CONFIG_FILE) \
		--OUTCOME_CONFIG_FILE=$(OUTCOME_CONFIG_FILE) \
		--PROJECT_CONFIG=$(PROJECT_CONFIG) \
		--RESAMPLING_RESULTS_FILE=$(RESAMPLING_RESULTS_FILE) \
		--RESAMPLING_BY_SUBGROUP_RESULTS_FILE=$(RESAMPLING_BY_SUBGROUP_RESULTS_FILE) \
		--OUT_DIR=$(OUT_DIR)

.PHONY: all clean
.DEFAULT_GOAL=all

all: $(OUT_FILE)

clean:
	rm -rf $(OUT_DIR)
